package com.yuexun.dhdoctor.module.survey.model.impl;


import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.survey.api.SurveyApi;
import com.yuexun.dhdoctor.module.survey.bean.StartSurveyBean;
import com.yuexun.dhdoctor.module.survey.bean.SurveyAnswerDtlBean;
import com.yuexun.dhdoctor.module.survey.bean.SurveyDateBean;
import com.yuexun.dhdoctor.module.survey.bean.SurveyDtlBean;
import com.yuexun.dhdoctor.module.survey.bean.SurveyTypeBean;
import com.yuexun.dhdoctor.module.survey.model.ISurveyModel;
import com.yuexun.dhdoctor.util.ApiUtil;

import java.util.Map;

import rx.Observable;

/**
 * Created by wangt on 2017/8/22.
 */

public class SurveyModel implements ISurveyModel {
    private SurveyApi api;

    public SurveyApi ApiInstance() {
        if (api != null) {
            return api;
        } else {
            return ApiUtil.getInstance().createRetrofitApi(SurveyApi.class);
        }
    }

    @Override
    public Observable<BaseEntity<SurveyTypeBean>> getSurveyTypeList(Map<String, String> praise) {
        api = ApiInstance();
        return api.getSurveyTypeList(praise);
    }

    @Override
    public Observable<BaseEntity<SurveyDateBean>> getSurveyList(Map<String, String> praise) {
        api = ApiInstance();
        return api.getSurveyList(praise);
    }

    @Override
    public Observable<BaseEntity<StartSurveyBean>> startSurvey(Map<String, String> praise) {
        api = ApiInstance();
        return api.startSurvey(praise);
    }

    @Override
    public Observable<BaseEntity<SurveyDtlBean>> getSurveyDtl(Map<String, String> praise) {
        api = ApiInstance();
        return api.getSurveyDtl(praise);
    }

    @Override
    public Observable<BaseEntity<SurveyAnswerDtlBean>> getSurveyAnswerDtl(Map<String, String> praise) {
        api = ApiInstance();
        return api.getSurveyAnswerDtl(praise);
    }

    @Override
    public Observable<BaseEntity<String>> updateSurveyAnswer(Map<String, String> praise) {
        api = ApiInstance();
        return api.updateSurveyAnswer(praise);
    }
}
